Skip to content

Conversation

@LeafShi1
Copy link
Member

@LeafShi1 LeafShi1 commented Apr 24, 2025

Fixes #13304

Proposed changes

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the handling of the OperationInReleasingDataSource flag and the subsequent cleanup of the DataGridView’s state when a bound data source is disposed. Key changes include removing the inline try–finally block that set the flag and reset CurrentCell from DataGridView.cs and moving that logic into a new dedicated method, OnDataSourceDisposed, in DataGridView.Methods.cs.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs Removed the inline try–finally disposal block so that the flag and CurrentCell reset are handled by OnDataSourceDisposed.
src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.Methods.cs Added a new OnDataSourceDisposed method that wraps setting DataSource and resetting CurrentCell within a try–finally block.
Comments suppressed due to low confidence (1)

src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs:1922

  • Verify that removing the inline try–finally block which sets _dataGridViewOper and resets CurrentCell does not affect any existing side effects in the property setter; ensure that all necessary state cleanup is now correctly handled by OnDataSourceDisposed.
-                _dataGridViewOper[OperationInReleasingDataSource] = true;

@codecov
Copy link

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.69342%. Comparing base (e966bca) to head (f20795a).
Report is 12 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                  @@
##                main      #13362          +/-   ##
====================================================
+ Coverage   62.59209%   95.69342%   +33.10133%     
====================================================
  Files           1560         542        -1018     
  Lines         159763       63461       -96302     
  Branches       14915        1451       -13464     
====================================================
- Hits           99999       60728       -39271     
+ Misses         58988        2400       -56588     
+ Partials         776         333         -443     
Flag Coverage Δ
Debug 95.69342% <ø> (+33.10133%) ⬆️
integration ?
production ?
test 95.69342% <ø> (ø)
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LeafShi1 LeafShi1 force-pushed the Moving-the-tag-OperationInReleasingDataSource-to-OnDataSourceDisposed branch from 4c202f0 to f0546b8 Compare April 24, 2025 02:36
@LeafShi1 LeafShi1 force-pushed the Moving-the-tag-OperationInReleasingDataSource-to-OnDataSourceDisposed branch from c0ff14b to 31d5a9b Compare April 24, 2025 04:08
@Tanya-Solyanik Tanya-Solyanik added the waiting-author-feedback The team requires more information from the author label Apr 24, 2025
@LeafShi1 LeafShi1 removed the waiting-author-feedback The team requires more information from the author label Apr 24, 2025
@Tanya-Solyanik
Copy link
Contributor

PLease update the servicing PRs

@LeafShi1 LeafShi1 merged commit dd8c71f into dotnet:main Apr 25, 2025
8 checks passed
LeafShi1 added a commit to LeafShi1/winforms that referenced this pull request Apr 25, 2025
…sposed" (dotnet#13362)

* Removing tag OperationInReleasingDataSource

* Add judgment IsHandleCreated to before defining currentCell in function SetCurrentCellAddressCore
LeafShi1 added a commit to LeafShi1/winforms that referenced this pull request Apr 25, 2025
…sposed" (dotnet#13362)

* Removing tag OperationInReleasingDataSource

* Add judgment IsHandleCreated to before defining currentCell in function SetCurrentCellAddressCore
LeafShi1 added a commit that referenced this pull request Apr 25, 2025
…sposed" (#13362)

* Removing tag OperationInReleasingDataSource 

* Add judgment IsHandleCreated to before defining currentCell in function SetCurrentCellAddressCore
LeafShi1 added a commit that referenced this pull request Apr 25, 2025
…sposed" (#13362)

* Removing tag OperationInReleasingDataSource 

* Add judgment IsHandleCreated to before defining currentCell in function SetCurrentCellAddressCore
@LeafShi1 LeafShi1 changed the title Moving tag OperationInReleasingDataSource to function "OnDataSourceDisposed" Removing flag OperationInReleasingDataSource from DataGridView.cs Apr 25, 2025
@LeafShi1 LeafShi1 deleted the Moving-the-tag-OperationInReleasingDataSource-to-OnDataSourceDisposed branch April 25, 2025 05:46
@LeafShi1 LeafShi1 mentioned this pull request May 12, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidOperationException when dialog containing focused DataGridView is closed

2 participants